import "./public-path";
import Vue from "vue";
import App from "./App.vue";

import router from "./router";

Vue.config.productionTip = false;

let vm = null;
// 渲染方法
function render(props = {}) {
  const { container } = props;
  vm = new Vue({
    router,
    render: (h) => h(App),
  }).$mount(container ? container.querySelector("#app") : "#app");
}

// 独立运行时
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}

// 在主应用渲染时，主应用会自动调用 bootstrap mount
// 在主应用卸载时，unmount
export async function bootstrap() {}
export async function mount(props) {
  render(props);
}
export async function unmount() {
  vm.$destroy();
  vm.$el.innerHTML = "";
}
